import Vue from 'vue'
import Vuex from 'vuex'

const files = require.context('./store', true, /\.js$/)

Vue.use(Vuex)

let modules = {}
files.keys().forEach(file => {
  const match = file.match(/(\w+)\.js$/)
  if (match.length) {
    modules[match[1]] = files(file).default
  }
})

export default new Vuex.Store({
  modules
})
